package com.example.simplemodule;

import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class CheckBoxTestActivity extends AppCompatActivity {

	private CheckBox check_box_man;
	private CheckBox check_box_woman;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_checkbox);

		this.check_box_man = (CheckBox) findViewById(R.id.checkbox_man);
		this.check_box_man.setOnCheckedChangeListener((buttonView, isChecked) -> {
			if(isChecked){
				Toast.makeText(this, "您选中了"+buttonView.getText().toString(), Toast.LENGTH_SHORT).show();
			}else{
				Toast.makeText(this, "您取消了选中"+buttonView.getText().toString(), Toast.LENGTH_SHORT).show();

			}
		});

		this.check_box_woman = (CheckBox) findViewById(R.id.checkbox_woman);
		this.check_box_woman.setOnCheckedChangeListener((buttonView, isChecked) -> {
			if(isChecked){
				Toast.makeText(this, "您选中了"+buttonView.getText().toString(), Toast.LENGTH_SHORT).show();
			}else{
				Toast.makeText(this, "您取消了选中"+buttonView.getText().toString(), Toast.LENGTH_SHORT).show();

			}
		});
	}
}
